home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / postgres / postgre3.z / postgre3 / src / lib / H / utils / nabstime.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-04-18  |  3.4 KB  |  132 lines

  1. /* $Header: /private/postgres/src/lib/H/utils/RCS/nabstime.h,v 1.2 1992/05/08 23:54:16 mer Exp $ */
  2.  
  3. #ifndef _NABSTIME_INCL_
  4. #define _NABSTIME_INCL_
  5.  
  6. #include <sys/types.h>
  7. #include <time.h>
  8.  
  9. /* ----------------------------------------------------------------
  10.  *        time types + support macros
  11.  *
  12.  *
  13.  * ----------------------------------------------------------------
  14.  */
  15. typedef uint32    AbsoluteTime;
  16.  
  17. typedef struct { 
  18.     int32    status;
  19.     Time    data[2];
  20. } TimeIntervalData;
  21. typedef TimeIntervalData *TimeInterval;
  22.  
  23. #define EPOCH_ABSTIME ((long) 4294967294UL)
  24. #define INVALID_ABSTIME ((long) 4294967295UL)
  25. #define InvalidAbsoluteTime    INVALID_ABSTIME
  26.  
  27. #define InvalidTime    INVALID_ABSTIME    /* XXX this will disappear */
  28.  
  29. /* ----------------
  30.  *    time support macros (from tim.h)
  31.  * ----------------
  32.  */
  33.  
  34. #define AbsoluteTimeIsValid(time) \
  35.     ((bool) ((time) != InvalidAbsoluteTime))
  36.  
  37. #define AbsoluteTimeIsReal(time) \
  38.     ((bool) (((unsigned)(time)) < (unsigned)EPOCH_ABSTIME))
  39.  
  40. #define RelativeTimeIsValid(time) \
  41.     ((bool) ((time) != InvalidRelativeTime))
  42.  
  43. #define TimeIsValid(time) AbsoluteTimeIsValid(time)
  44.  
  45. #define GetCurrentAbsoluteTime() \
  46.     ((Time) GetSystemTime())
  47.  
  48. /* XXX remove this */
  49. #define GetCurrentTime() \
  50.     ((AbsoluteTime) GetCurrentAbsoluteTime())
  51.  
  52. /*
  53.  * GetSystemTime --
  54.  *    Returns system time.
  55.  */
  56. #define GetSystemTime() \
  57.     ((SystemTime) (time(0l)))
  58.  
  59. /*
  60.  *  Meridian:  am, pm, or 24-hour style.
  61.  */
  62. #define AM 0
  63. #define PM 1
  64. #define HR24 2
  65.  
  66. /* can't have more of these than there are bits in an unsigned long */
  67. #define MONTH    1
  68. #define YEAR    2
  69. #define DAY    3
  70. #define TIME    4
  71. #define TZ    5
  72. #define DTZ    6
  73. #define IGNORE    7
  74. #define AMPM    8
  75. /* below here are unused so far */
  76. #define SECONDS    9
  77. #define MONTHS    10
  78. #define YEARS    11
  79. #define NUMBER    12
  80. /* these are only for relative dates */
  81. #define ABS_BEFORE    13
  82. #define ABS_AFTER    14
  83. #define AGO    15
  84.  
  85.  
  86. #define SECS(n)        ((time_t)(n))
  87. #define MINS(n)        ((time_t)(n) * SECS(60))
  88. #define HOURS(n)    ((time_t)(n) * MINS(60))    /* 3600 secs */
  89. #define DAYS(n)        ((time_t)(n) * HOURS(24))    /* 86400 secs */
  90. /* months and years are not constant length, must be specially dealt with */
  91.  
  92. #define TOKMAXLEN 6    /* only this many chars are stored in datetktbl */
  93.  
  94. /* keep this struct small; it gets used a lot */
  95. typedef struct {
  96.     char token[TOKMAXLEN];
  97.     char type;
  98.     char value;        /* this may be unsigned, alas */
  99. } datetkn;
  100.  
  101.  
  102. /* nabstime.c prototypes */
  103.  
  104. AbsoluteTime nabstimein ARGS((char *timestr ));
  105. char *nabstimeout ARGS((AbsoluteTime time ));
  106.  
  107. /* Almost everybody includes this file, and make GNU cc complain about
  108.    struct timeb defined in argument list. Declare it! */
  109. #ifdef linux
  110. struct timeb;
  111. #endif
  112. int prsabsdate ARGS((char *timestr,struct timeb *now, struct tm *tm, int *tzp));
  113. int parsetime ARGS((char *time , struct tm *tm ));
  114. int split ARGS((char *string , char *fields [], int nfields , char *sep ));
  115. int MonthNumToStr ARGS((int mnum , char *mstr ));
  116. int WeekdayToStr ARGS((int wday , char *wstr ));
  117. int IsNowStr ARGS((char *tstr ));
  118. int IsEpochStr ARGS((char *tstr ));
  119.  
  120. int tryabsdate ARGS((char *fields[],int nf,struct timeb *now,struct tm *tm,int *tzp));
  121.  
  122. datetkn *datebsearch ARGS((char *key , datetkn *base , unsigned int nel ));
  123. datetkn *datetoktype ARGS((char *s , int *bigvalp ));
  124.  
  125. AbsoluteTime dateconv ARGS((struct tm *tm , int zone ));
  126. time_t qmktime ARGS((struct tm *tp ));
  127.  
  128. bool AbsoluteTimeIsBefore ARGS((AbsoluteTime time1 , AbsoluteTime time2 ));
  129. bool AbsoluteTimeIsAfter ARGS((AbsoluteTime time1 , AbsoluteTime time2 ));
  130.  
  131. #endif _NABSTIME_INCL_
  132.